<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用ref</title>
</head>

<body>
    <div id="app">
        <two-component ref="aaa"></two-component>
        <button @click="changeBlood">点我改变血量</button>
    </div>
</body>
<script src="../day06/lib/vue.js"></script>
<script>
    let twoComponent = {
        data() {
            return {
                name: '组件B',
                blood: 100
            }
        },
        template:
            `
        <div style="border:1px solid green;">
            <div>我是{{name}},我当前的血量是{{blood}}</div>
        </div>
        `
    }
    new Vue({
        el: '#app',
        components: {
            twoComponent,
        },
        mounted() {
            this.$refs.aaa.blood = 100
        }
        ,
        methods: {
            changeBlood() {
                // this.$refs.aaa = 1000
                this.$refs.aaa.blood += 100
            }
        }
    })
</script>

</html>